package com.example.controller;
import com.example.common.Result;
import com.example.model.SysUser;
import com.example.service.SysUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@RestController
@RequestMapping("/api/sysUser")
public class SysUserControler {
    @Resource
    public SysUserService sysUserService;

    @PostMapping("/select")
    public SysUser selectLoginUser(@RequestBody SysUser sysUser) {
        return  sysUserService.selectSysUserById(sysUser.getTid());
    }

    @PostMapping("/insert")
    public Result insertSysUser(@RequestBody SysUser sysUser) {
        int count = sysUserService.insertSysUser(sysUser);
        if(count > 0) {
            return Result.ok("新增记录成功。。。");
        }
        return Result.error("新增记录失败。。。");
    }

    @PostMapping("/update")
    public String updateSysUser(@RequestBody SysUser sysUser) {
        int count = sysUserService.updateSysUser(sysUser);
        if(count > 0) {
            return "修改记录成功。。。";
        }
        return "修改记录失败。。。";
    }

    @PostMapping("/delete")
    public String deleteSysUser(@RequestBody SysUser sysUser) {
        int count = sysUserService.deleteSysUserById(sysUser.getTid());
        if(count > 0) {
            return "删除记录成功。。。";
        }
        return "删除记录失败。。。";
    }
}
